FROM 10.0.46.66:5000/golang:1.23 AS builder

WORKDIR /building

RUN go env -w GO111MODULE=on
RUN go env -w GOPROXY=https://goproxy.cn,direct

COPY go.mod go.sum ./
RUN go mod download

COPY . .

RUN env CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -tags frps -o /building/server main.go

FROM 10.0.46.66:5000/alpine:3

RUN apk add --no-cache tzdata

WORKDIR /app

COPY --from=builder /building/server .
RUN chmod +x server

EXPOSE 8080

ENV DB_HOST="10.0.42.52:3306"
ENV DB_NAME="swu"
ENV DB_USER="root"
ENV DB_PASSWORD="sde!23$sW"

ENV GIN_MODE=release
ENV TZ=Asia/Shanghai

ENTRYPOINT ["/app/server"]